//
//  RMMChongZhiView.m
//  Romomo
//
//  Created by puman on 16/10/17.
//  Copyright © 2016年 mazegong. All rights reserved.
//

#import "RMMChongZhiView.h"

@implementation RMMChongZhiView
- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = RGBA(245, 246, 247, 1);
        UIView *headView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWideth, 136)];
        headView.backgroundColor = kBasicColor;
        [self addSubview:headView];
        
        for (int i = 0; i < 2; i++) {
            UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 34 + kMaric * i, kScreenWideth, kMaric + 30 * i)];
            label.textAlignment = NSTextAlignmentCenter;
            label.textColor = kWhiteColor;
            [headView addSubview:label];
            if (i == 0) {
                label.text = @"会员卡余额";
                label.font = kFont(14);
            } else {
                label.text = @"¥900";
                label.font = kFont(36);
                _label = label;
            }
        }
        
        UIView *bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, headView.bottom, kScreenWideth, 240)];
        bottomView.backgroundColor = kWhiteColor;
        [self addSubview:bottomView];
        
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(15, 0, kScreenWideth, 44)];
        label.text = @"选择充值金额";
        label.textColor = COLORFROMCODE(0x4A4A4A, 1);
        label.font = kFont(13);
        [bottomView addSubview:label];
        CGFloat x = (kScreenWideth - 270 - 32) / 2;
        for (int i = 0; i < 6; i++) {
            UIButton *button = [UIButton buttonWithType:(UIButtonTypeCustom)];
            button.frame = CGRectMake(x + 106 * (i  % 3), 60 + 70 * (i / 3), 90, 54);
            button.layer.borderWidth = 1;
            button.layer.borderColor = COLORFROMCODE(0x87D7D7 , 1).CGColor;
            button.layer.cornerRadius = 3;
            button.titleLabel.font = kFont(18);
            button.tag = 10 + i;
            [button setTitleColor:kBasicColor forState:(UIControlStateNormal)];
            [bottomView addSubview:button];
            if (i == 5) {
                UILabel *bottomLabel = [[UILabel alloc] initWithFrame:CGRectMake(x, button.bottom + 16, bottomView.width - 2 * x, 40)];
                bottomLabel.numberOfLines = 0;
                bottomLabel.text = @"注: 实时到账。部分商品使用会员卡支付可享受9折优惠";
                bottomLabel.textColor = COLORFROMCODE(0xBFBFBF, 1);
                bottomLabel.font = kFont(13);
                [bottomView addSubview:bottomLabel];
            }
        }
        
       _chongZhiBut = [UIButton buttonWithType:(UIButtonTypeCustom)];
        _chongZhiBut.frame = CGRectMake(28, self.height - 80, kScreenWideth - 56, 40);
        _chongZhiBut.backgroundColor = COLORFROMCODE(0xEEEEEE, 1);
        [_chongZhiBut setTitleColor:COLORFROMCODE(0xD7D7D7 , 1) forState:(UIControlStateNormal)];
        _chongZhiBut.titleLabel.font = kBFont(16);
        _chongZhiBut.layer.masksToBounds = YES;
        _chongZhiBut.userInteractionEnabled = NO;
        _chongZhiBut.layer.cornerRadius = kMaric;
        [_chongZhiBut setTitle:@"立即充值" forState:(UIControlStateNormal)];
        [self addSubview:_chongZhiBut];

    }
    return self;
}
- (void)setDataArray:(NSArray *)dataArray{
    for (int i = 0; i < 6; i++) {
        UIButton *button = [self viewWithTag:10 + i];
        [button setTitle:[NSString stringWithFormat:@"¥%@",dataArray[i]] forState:(UIControlStateNormal)];
    }
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
